<?php 
class ConfirmcartController extends CommonController{
	
	
	public function __init(){
		if(!session('uid')){
			go(U('Member/login'));
		}
		if(!session('cart')){
			go(U('Index/index'));
		}
		
		
	}
	
	public function index(){
		$uid=$_SESSION['uid'];
		$dress=K("Address")->where("user_uid={$uid}")->all();
		$this->assign('dress',$dress);
		
		$this->display();
	}
	
	
	
	/**
	 * 添加地址
	 */
	public function dressadd(){
		if(IS_POST){
			if(!K("Address")->adddress()) $this->error(K("Address")->error);
			$this->success("添加成功");
		}
		
		
		
	}
	/**
	 * 删除地址
	 */
	 public function deldress(){
	 	$adid=Q("get.adid","","intval");
		K("Address")->where("adid={$adid}")->delete();
		$this->success("删除成功");
	 }
	 
	 /**
	  * 编辑地址
	  */
	  public function edit(){
	  	if(IS_POST){
	  		if(!K("Address")->edit()) $this->error(K("Address")->error);
			$this->success("编辑成功",U("index"));
	  		
	  		
	  	}
    //获得旧数据
    $adid=Q("get.adid","","intval");
	$dress=K("Address")->where("adid={$adid}")->find();
	  	$this->assign('dress',$dress);
	  	$this->display();
	  }
	 
	
	
}





 ?>